home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / internals.info-2.z / internals.info-2
Encoding:
GNU Info File  |  1998-05-21  |  50.0 KB  |  1,117 lines

  1. This is Info file ../../info/internals.info, produced by Makeinfo
  2. version 1.68 from the input file internals.texi.
  3.  
  4.    Copyright (C) 1992 - 1996 Ben Wing.  Copyright (C) 1996, 1997 Sun
  5. Microsystems.  Copyright (C) 1994, 1995 Free Software Foundation.
  6. Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that the
  14. entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.  
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that this permission notice may be stated in a
  20. translation approved by the Foundation.
  21.  
  22.    Permission is granted to copy and distribute modified versions of
  23. this manual under the conditions for verbatim copying, provided also
  24. that the section entitled "GNU General Public License" is included
  25. exactly as in the original, and provided that the entire resulting
  26. derived work is distributed under the terms of a permission notice
  27. identical to this one.
  28.  
  29.    Permission is granted to copy and distribute translations of this
  30. manual into another language, under the above conditions for modified
  31. versions, except that the section entitled "GNU General Public License"
  32. may be included in a translation approved by the Free Software
  33. Foundation instead of in the original English.
  34.  
  35. 
  36. File: internals.info,  Node: The XEmacs Object System (Abstractly Speaking),  Next: How Lisp Objects Are Represented in C,  Prev: XEmacs From the Inside,  Up: Top
  37.  
  38. The XEmacs Object System (Abstractly Speaking)
  39. **********************************************
  40.  
  41.    At the heart of the Lisp interpreter is its management of objects.
  42. XEmacs Lisp contains many built-in objects, some of which are simple
  43. and others of which can be very complex; and some of which are very
  44. common, and others of which are rarely used or are only used
  45. internally. (Since the Lisp allocation system, with its automatic
  46. reclamation of unused storage, is so much more convenient than
  47. `malloc()' and `free()', the C code makes extensive use of it in its
  48. internal operations.)
  49.  
  50.    The basic Lisp objects are
  51.  
  52. `integer'
  53.      28 bits of precision, or 60 bits on 64-bit machines; the reason
  54.      for this is described below when the internal Lisp object
  55.      representation is described.
  56.  
  57. `float'
  58.      Same precision as a double in C.
  59.  
  60. `cons'
  61.      A simple container for two Lisp objects, used to implement lists
  62.      and most other data structures in Lisp.
  63.  
  64. `char'
  65.      An object representing a single character of text; chars behave
  66.      like integers in many ways but are logically considered text
  67.      rather than numbers and have a different read syntax. (the read
  68.      syntax for a char contains the char itself or some textual
  69.      encoding of it - for example, a Japanese Kanji character might be
  70.      encoded as `^[$(B#&^[(B' using the ISO-2022 encoding standard -
  71.      rather than the numerical representation of the char; this way, if
  72.      the mapping between chars and integers changes, which is quite
  73.      possible for Kanji characters and other extended characters, the
  74.      same character will still be created.  Note that some primitives
  75.      confuse chars and integers.  The worst culprit is `eq', which
  76.      makes a special exception and considers a char to be `eq' to its
  77.      integer equivalent, even though in no other case are objects of two
  78.      different types `eq'.  The reason for this monstrosity is
  79.      compatibility with existing code; the separation of char from
  80.      integer came fairly recently.)
  81.  
  82. `symbol'
  83.      An object that contains Lisp objects and is referred to by name;
  84.      symbols are used to implement variables and named functions and to
  85.      provide the equivalent of preprocessor constants in C.
  86.  
  87. `vector'
  88.      A one-dimensional array of Lisp objects providing constant-time
  89.      access to any of the objects; access to an arbitrary object in a
  90.      vector is faster than for lists, but the operations that can be
  91.      done on a vector are more limited.
  92.  
  93. `string'
  94.      Self-explanatory; behaves much like a vector of chars but has a
  95.      different read syntax and is stored and manipulated more compactly
  96.      and efficiently.
  97.  
  98. `bit-vector'
  99.      A vector of bits; similar to a string in spirit.
  100.  
  101. `compiled-function'
  102.      An object describing compiled Lisp code, known as "byte code".
  103.  
  104. `subr'
  105.      An object describing a Lisp primitive.
  106.  
  107.    Note that there is no basic "function" type, as in more powerful
  108. versions of Lisp (where it's called a "closure").  XEmacs Lisp does not
  109. provide the closure semantics implemented by Common Lisp and Scheme.
  110. The guts of a function in XEmacs Lisp are represented in one of four
  111. ways: a symbol specifying another function (when one function is an
  112. alias for another), a list containing the function's source code, a
  113. bytecode object, or a subr object. (In other words, given a symbol
  114. specifying the name of a function, calling `symbol-function' to
  115. retrieve the contents of the symbol's function cell will return one of
  116. these types of objects.)
  117.  
  118.    XEmacs Lisp also contains numerous specialized objects used to
  119. implement the editor:
  120.  
  121. `buffer'
  122.      Stores text like a string, but is optimized for insertion and
  123.      deletion and has certain other properties that can be set.
  124.  
  125. `frame'
  126.      An object with various properties whose displayable representation
  127.      is a "window" in window-system parlance.
  128.  
  129. `window'
  130.      A section of a frame that displays the contents of a buffer; often
  131.      called a "pane" in window-system parlance.
  132.  
  133. `window-configuration'
  134.      An object that represents a saved configuration of windows in a
  135.      frame.
  136.  
  137. `device'
  138.      An object representing a screen on which frames can be displayed;
  139.      equivalent to a "display" in the X Window System and a "TTY" in
  140.      character mode.
  141.  
  142. `face'
  143.      An object specifying the appearance of text or graphics; it
  144.      contains characteristics such as font, foreground color, and
  145.      background color.
  146.  
  147. `marker'
  148.      An object that refers to a particular position in a buffer and
  149.      moves around as text is inserted and deleted to stay in the same
  150.      relative position to the text around it.
  151.  
  152. `extent'
  153.      Similar to a marker but covers a range of text in a buffer; can
  154.      also specify properties of the text, such as a face in which the
  155.      text is to be displayed, whether the text is invisible or
  156.      unmodifiable, etc.
  157.  
  158. `event'
  159.      Generated by calling `next-event' and contains information
  160.      describing a particular event happening in the system, such as the
  161.      user pressing a key or a process terminating.
  162.  
  163. `keymap'
  164.      An object that maps from events (described using lists, vectors,
  165.      and symbols rather than with an event object because the mapping
  166.      is for classes of events, rather than individual events) to
  167.      functions to execute or other events to recursively look up; the
  168.      functions are described by name, using a symbol, or using lists to
  169.      specify the function's code.
  170.  
  171. `glyph'
  172.      An object that describes the appearance of an image (e.g.  pixmap)
  173.      on the screen; glyphs can be attached to the beginning or end of
  174.      extents and in some future version of XEmacs will be able to be
  175.      inserted directly into a buffer.
  176.  
  177. `process'
  178.      An object that describes a connection to an externally-running
  179.      process.
  180.  
  181.    There are some other, less-commonly-encountered general objects:
  182.  
  183. `hashtable'
  184.      An object that maps from an arbitrary Lisp object to another
  185.      arbitrary Lisp object, using hashing for fast lookup.
  186.  
  187. `obarray'
  188.      A limited form of hashtable that maps from strings to symbols;
  189.      obarrays are used to look up a symbol given its name and are not
  190.      actually their own object type but are kludgily represented using
  191.      vectors with hidden fields (this representation derives from GNU
  192.      Emacs).
  193.  
  194. `specifier'
  195.      A complex object used to specify the value of a display property; a
  196.      default value is given and different values can be specified for
  197.      particular frames, buffers, windows, devices, or classes of device.
  198.  
  199. `char-table'
  200.      An object that maps from chars or classes of chars to arbitrary
  201.      Lisp objects; internally char tables use a complex nested-vector
  202.      representation that is optimized to the way characters are
  203.      represented as integers.
  204.  
  205. `range-table'
  206.      An object that maps from ranges of integers to arbitrary Lisp
  207.      objects.
  208.  
  209.    And some strange special-purpose objects:
  210.  
  211. `charset'
  212. `coding-system'
  213.      Objects used when MULE, or multi-lingual/Asian-language, support is
  214.      enabled.
  215.  
  216. `color-instance'
  217. `font-instance'
  218. `image-instance'
  219.      An object that encapsulates a window-system resource; instances are
  220.      mostly used internally but are exposed on the Lisp level for
  221.      cleanness of the specifier model and because it's occasionally
  222.      useful for Lisp program to create or query the properties of
  223.      instances.
  224.  
  225. `subwindow'
  226.      An object that encapsulate a "subwindow" resource, i.e. a
  227.      window-system child window that is drawn into by an external
  228.      process; this object should be integrated into the glyph system
  229.      but isn't yet, and may change form when this is done.
  230.  
  231. `tooltalk-message'
  232. `tooltalk-pattern'
  233.      Objects that represent resources used in the ToolTalk interprocess
  234.      communication protocol.
  235.  
  236. `toolbar-button'
  237.      An object used in conjunction with the toolbar.
  238.  
  239. `x-resource'
  240.      An object that encapsulates certain miscellaneous resources in the
  241.      X window system, used only when Epoch support is enabled.
  242.  
  243.    And objects that are only used internally:
  244.  
  245. opaque
  246.      A generic object for encapsulating arbitrary memory; this allows
  247.      you the generality of `malloc()' and the convenience of the Lisp
  248.      object system.
  249.  
  250. lstream
  251.      A buffering I/O stream, used to provide a unified interface to
  252.      anything that can accept output or provide input, such as a file
  253.      descriptor, a stdio stream, a chunk of memory, a Lisp buffer, a
  254.      Lisp string, etc.; it's a Lisp object to make its memory
  255.      management more convenient.
  256.  
  257. char-table-entry
  258.      Subsidiary objects in the internal char-table representation.
  259.  
  260. extent-auxiliary
  261. menubar-data
  262. toolbar-data
  263.      Various special-purpose objects that are basically just used to
  264.      encapsulate memory for particular subsystems, similar to the more
  265.      general "opaque" object.
  266.  
  267. symbol-value-forward
  268. symbol-value-buffer-local
  269. symbol-value-varalias
  270. symbol-value-lisp-magic
  271.      Special internal-only objects that are placed in the value cell of
  272.      a symbol to indicate that there is something special with this
  273.      variable - e.g. it has no value, it mirrors another variable, or
  274.      it mirrors some C variable; there is really only one kind of
  275.      object, called a "symbol-value-magic", but it is sort-of halfway
  276.      kludged into semi-different object types.
  277.  
  278.    Some types of objects are "permanent", meaning that once created,
  279. they do not disappear until explicitly destroyed, using a function such
  280. as `delete-buffer', `delete-window', `delete-frame', etc.  Others will
  281. disappear once they are not longer used, through the garbage collection
  282. mechanism.  Buffers, frames, windows, devices, and processes are among
  283. the objects that are permanent.  Note that some objects can go both
  284. ways: Faces can be created either way; extents are normally permanent,
  285. but detached extents (extents not referring to any text, as happens to
  286. some extents when the text they are referring to is deleted) are
  287. temporary.  Note that some permanent objects, such as faces and coding
  288. systems, cannot be deleted.  Note also that windows are unique in that
  289. they can be *undeleted* after having previously been deleted. (This
  290. happens as a result of restoring a window configuration.)
  291.  
  292.    Note that many types of objects have a "read syntax", i.e. a way of
  293. specifying an object of that type in Lisp code.  When you load a Lisp
  294. file, or type in code to be evaluated, what really happens is that the
  295. function `read' is called, which reads some text and creates an object
  296. based on the syntax of that text; then `eval' is called, which possibly
  297. does something special; then this loop repeats until there's no more
  298. text to read. (`eval' only actually does something special with
  299. symbols, which causes the symbol's value to be returned, similar to
  300. referencing a variable; and with conses [i.e. lists], which cause a
  301. function invocation.  All other values are returned unchanged.)
  302.  
  303.    The read syntax
  304.  
  305.      17297
  306.  
  307.    converts to an integer whose value is 17297.
  308.  
  309.      1.983e-4
  310.  
  311.    converts to a float whose value is 1983.23e-4, or .0001983.
  312.  
  313.      ?b
  314.  
  315.    converts to a char that represents the lowercase letter b.
  316.  
  317.      ?^[$(B#&^[(B
  318.  
  319.    (where `^[' actually is an `ESC' character) converts to a particular
  320. Kanji character when using an ISO2022-based coding system for input.
  321. (To decode this gook: `ESC' begins an escape sequence; `ESC $ (' is a
  322. class of escape sequences meaning "switch to a 94x94 character set";
  323. `ESC $ ( B' means "switch to Japanese Kanji"; `#' and `&' collectively
  324. index into a 94-by-94 array of characters [subtract 33 from the ASCII
  325. value of each character to get the corresponding index]; `ESC (' is a
  326. class of escape sequences meaning "switch to a 94 character set"; `ESC
  327. (B' means "switch to US ASCII".  It is a coincidence that the letter
  328. `B' is used to denote both Japanese Kanji and US ASCII.  If the first
  329. `B' were replaced with an `A', you'd be requesting a Chinese Hanzi
  330. character from the GB2312 character set.)
  331.  
  332.      "foobar"
  333.  
  334.    converts to a string.
  335.  
  336.      foobar
  337.  
  338.    converts to a symbol whose name is `"foobar"'.  This is done by
  339. looking up the string equivalent in the global variable `obarray',
  340. whose contents should be an obarray.  If no symbol is found, a new
  341. symbol with the name `"foobar"' is automatically created and adding it
  342. to `obarray'; this process is called "interning" the symbol.
  343.  
  344.      (foo . bar)
  345.  
  346.    converts to a cons cell containing the symbols `foo' and `bar'.
  347.  
  348.      (1 a 2.5)
  349.  
  350.    converts to a three-element list containing the specified objects
  351. (note that a list is actually a set of nested conses; see the XEmacs
  352. Lisp Reference).
  353.  
  354.      [1 a 2.5]
  355.  
  356.    converts to a three-element vector containing the specified objects.
  357.  
  358.      #[... ... ... ...]
  359.  
  360.    converts to a compiled-function object (the actual contents are not
  361. shown since they are not relevant here; look at a file that ends with
  362. `.elc' for examples).
  363.  
  364.      #*01110110
  365.  
  366.    converts to a bit-vector.
  367.  
  368.      #s(range-table ... ...)
  369.  
  370.    converts to a range table (the actual contents are not shown).
  371.  
  372.      #s(char-table ... ...)
  373.  
  374.    converts to a char table (the actual contents are not shown).  (Note
  375. that the #s syntax is the general syntax for structures, which are not
  376. really implemented in XEmacs Lisp but should be.)
  377.  
  378.    When an object is printed out (using `print' or a related function),
  379. the read syntax is used, so that the same object can be read in again.
  380.  
  381.    The other objects do not have read syntaxes, usually because it does
  382. not really make sense to create them in this fashion (i.e.  processes,
  383. where it doesn't make sense to have a subprocess created as a side
  384. effect of reading some Lisp code), or because they can't be created at
  385. all (e.g. subrs).  Permanent objects, as a rule, do not have a read
  386. syntax; nor do most complex objects, which contain too much state to be
  387. easily initialized through a read syntax.
  388.  
  389. 
  390. File: internals.info,  Node: How Lisp Objects Are Represented in C,  Next: Rules When Writing New C Code,  Prev: The XEmacs Object System (Abstractly Speaking),  Up: Top
  391.  
  392. How Lisp Objects Are Represented in C
  393. *************************************
  394.  
  395.    Lisp objects are represented in C using a 32- or 64-bit machine word
  396. (depending on the processor; i.e. DEC Alphas use 64-bit Lisp objects and
  397. most other processors use 32-bit Lisp objects).  The representation
  398. stuffs a pointer together with a tag, as follows:
  399.  
  400.       [ 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ]
  401.       [ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 ]
  402.      
  403.         ^ <---> <------------------------------------------------------>
  404.         |  tag         a pointer to a structure, or an integer
  405.         |
  406.         `---> mark bit
  407.  
  408.    The tag describes the type of the Lisp object.  For integers and
  409. chars, the lower 28 bits contain the value of the integer or char; for
  410. all others, the lower 28 bits contain a pointer.  The mark bit is used
  411. during garbage-collection, and is always 0 when garbage collection is
  412. not happening.  Many macros that extract out parts of a Lisp object
  413. expect that the mark bit is 0, and will produce incorrect results if
  414. it's not. (The way that garbage collection works, basically, is that it
  415. loops over all places where Lisp objects could exist - this includes
  416. all global variables in C that contain Lisp objects [including
  417. `Vobarray', the C equivalent of `obarray'; through this, all Lisp
  418. variables will get marked], plus various other places - and recursively
  419. scans through the Lisp objects, marking each object it finds by setting
  420. the mark bit.  Then it goes through the lists of all objects allocated,
  421. freeing the ones that are not marked and turning off the mark bit of
  422. the ones that are marked.)
  423.  
  424.    Lisp objects use the typedef `Lisp_Object', but the actual C type
  425. used for the Lisp object can vary.  It can be either a simple type
  426. (`long' on the DEC Alpha, `int' on other machines) or a structure whose
  427. fields are bit fields that line up properly (actually, it's a union of
  428. structures that's used).  Generally the simple integral type is
  429. preferable because it ensures that the compiler will actually use a
  430. machine word to represent the object (some compilers will use more
  431. general and less efficient code for unions and structs even if they can
  432. fit in a machine word).  The union type, however, has the advantage of
  433. stricter type checking (if you accidentally pass an integer where a Lisp
  434. object is desired, you get a compile error), and it makes it easier to
  435. decode Lisp objects when debugging.  The choice of which type to use is
  436. determined by the presence or absence of the preprocessor constant
  437. `NO_UNION_TYPE'.  (Shouldn't it be `USE_UNION_TYPE', with opposite
  438. semantics?  "Hysterical reasons", of course.)
  439.  
  440.    Note that there are only eight types that the tag can represent, but
  441. many more actual types than this.  This is handled by having one of the
  442. tag types specify a meta-type called a "record"; for all such objects,
  443. the first four bytes of the pointed-to structure indicate what the
  444. actual type is.
  445.  
  446.    Note also that having 28 bits for pointers and integers restricts a
  447. lot of things to 256 megabytes of memory. (Basically, enough pointers
  448. and indices and whatnot get stuffed into Lisp objects that the total
  449. amount of memory used by XEmacs can't grow above 256 megabytes.  In
  450. older versions of XEmacs and GNU Emacs, the tag was 5 bits wide,
  451. allowing for 32 types, which was more than the actual number of types
  452. that existed at the time, and no "record" type was necessary.  However,
  453. this limited the editor to 64 megabytes total, which some users who
  454. edited large files might conceivably exceed.)
  455.  
  456.    Also, note that there is an implicit assumption here that all
  457. pointers are low enough that the top bits are all zero and can just be
  458. chopped off.  On standard machines that allocate memory from the bottom
  459. up (and give each process its own address space), this works fine.  Some
  460. machines, however, put the data space somewhere else in memory (e.g.
  461. beginning at 0x80000000).  Those machines cope by defining
  462. `DATA_SEG_BITS' in the corresponding `m/' or `s/' file to the proper
  463. mask.  Then, pointers retrieved from Lisp objects are automatically
  464. OR'ed with this value prior to being used.
  465.  
  466.    A corollary of the previous paragraph is that *(pointers to)
  467. stack-allocated structures cannot be put into Lisp objects*.  The stack
  468. is generally located near the top of memory; if you put such a pointer
  469. into a Lisp object, it will get its top bits chopped off, and you will
  470. lose.
  471.  
  472.    Various macros are used to construct Lisp objects and extract the
  473. components.  Macros of the form `XINT()', `XCHAR()', `XSTRING()',
  474. `XSYMBOL()', etc. mask out the pointer/integer field and cast it to the
  475. appropriate type.  All of the macros that construct pointers will `OR'
  476. with `DATA_SEG_BITS' if necessary.  `XINT()' needs to be a bit tricky
  477. so that negative numbers are properly sign-extended: Usually it does
  478. this by shifting the number four bits to the left and then four bits to
  479. the right.  This assumes that the right-shift operator does an
  480. arithmetic shift (i.e. it leaves the most-significant bit as-is rather
  481. than shifting in a zero, so that it mimics a divide-by-two even for
  482. negative numbers).  Not all machines/compilers do this, and on the ones
  483. that don't, a more complicated definition is selected by defining
  484. `EXPLICIT_SIGN_EXTEND'.
  485.  
  486.    Note that when `ERROR_CHECK_TYPECHECK' is defined, the extractor
  487. macros become more complicated - they check the tag bits and/or the
  488. type field in the first four bytes of a record type to ensure that the
  489. object is really of the correct type.  This is great for catching places
  490. where an incorrect type is being dereferenced - this typically results
  491. in a pointer being dereferenced as the wrong type of structure, with
  492. unpredictable (and sometimes not easily traceable) results.
  493.  
  494.    There are similar `XSETTYPE()' macros that construct a Lisp object.
  495. These macros are of the form `XSETTYPE (LVALUE, RESULT)', i.e. they
  496. have to be a statement rather than just used in an expression.  The
  497. reason for this is that standard C doesn't let you "construct" a
  498. structure (but GCC does).  Granted, this sometimes isn't too convenient;
  499. for the case of integers, at least, you can use the function
  500. `make_number()', which constructs and *returns* an integer Lisp object.
  501. Note that the `XSETTYPE()' macros are also affected by
  502. `ERROR_CHECK_TYPECHECK' and make sure that the structure is of the
  503. right type in the case of record types, where the type is contained in
  504. the structure.
  505.  
  506. 
  507. File: internals.info,  Node: Rules When Writing New C Code,  Next: A Summary of the Various XEmacs Modules,  Prev: How Lisp Objects Are Represented in C,  Up: Top
  508.  
  509. Rules When Writing New C Code
  510. *****************************
  511.  
  512.    The XEmacs C Code is extremely complex and intricate, and there are
  513. many rules that are more or less consistently followed throughout the
  514. code.  Many of these rules are not obvious, so they are explained here.
  515. It is of the utmost importance that you follow them.  If you don't,
  516. you may get something that appears to work, but which will crash in odd
  517. situations, often in code far away from where the actual breakage is.
  518.  
  519. * Menu:
  520.  
  521. * General Coding Rules::
  522. * Writing Lisp Primitives::
  523. * Adding Global Lisp Variables::
  524. * Techniques for XEmacs Developers::
  525.  
  526. 
  527. File: internals.info,  Node: General Coding Rules,  Next: Writing Lisp Primitives,  Up: Rules When Writing New C Code
  528.  
  529. General Coding Rules
  530. ====================
  531.  
  532.    Almost every module contains a `syms_of_*()' function and a
  533. `vars_of_*()' function.  The former declares any Lisp primitives you
  534. have defined and defines any symbols you will be using.  The latter
  535. declares any global Lisp variables you have added and initializes global
  536. C variables in the module.  For each such function, declare it in
  537. `symsinit.h' and make sure it's called in the appropriate place in
  538. `emacs.c'.  *Important*: There are stringent requirements on exactly
  539. what can go into these functions.  See the comment in `emacs.c'.  The
  540. reason for this is to avoid obscure unwanted interactions during
  541. initialization.  If you don't follow these rules, you'll be sorry!  If
  542. you want to do anything that isn't allowed, create a
  543. `complex_vars_of_*()' function for it.  Doing this is tricky, though:
  544. You have to make sure your function is called at the right time so that
  545. all the initialization dependencies work out.
  546.  
  547.    Every module includes `<config.h>' (angle brackets so that
  548. `--srcdir' works correctly; `config.h' may or may not be in the same
  549. directory as the C sources) and `lisp.h'.  `config.h' should always be
  550. included before any other header files (including system header files)
  551. to ensure that certain tricks played by various `s/' and `m/' files
  552. work out correctly.
  553.  
  554.    *All global and static variables that are to be modifiable must be
  555. declared uninitialized.*  This means that you may not use the "declare
  556. with initializer" form for these variables, such as `int some_variable
  557. = 0;'.  The reason for this has to do with some kludges done during the
  558. dumping process: If possible, the initialized data segment is re-mapped
  559. so that it becomes part of the (unmodifiable) code segment in the
  560. dumped executable.  This allows this memory to be shared among multiple
  561. running XEmacs processes.  XEmacs is careful to place as much constant
  562. data as possible into initialized variables (in particular, into what's
  563. called the "pure space" - see below) during the `temacs' phase.
  564.  
  565.    *Note:* This kludge only works on a few systems nowadays, and is
  566. rapidly becoming irrelevant because most modern operating systems
  567. provide "copy-on-write" semantics.  All data is initially shared between
  568. processes, and a private copy is automatically made (on a page-by-page
  569. basis) when a process first attempts to write to a page of memory.
  570.  
  571.    Formerly, there was a requirement that static variables not be
  572. declared inside of functions.  This had to do with another hack along
  573. the same vein as what was just described: old USG systems put
  574. statically-declared variables in the initialized data space, so those
  575. header files had a `#define static' declaration. (That way, the
  576. data-segment remapping described above could still work.) This fails
  577. badly on static variables inside of functions, which suddenly become
  578. automatic variables; therefore, you weren't supposed to have any of
  579. them.  This awful kludge has been removed in XEmacs because
  580.  
  581.   1. almost all of the systems that used this kludge ended up having to
  582.      disable the data-segment remapping anyway;
  583.  
  584.   2. the only systems that didn't were extremely outdated ones;
  585.  
  586.   3. this hack completely messed up inline functions.
  587.  
  588. 
  589. File: internals.info,  Node: Writing Lisp Primitives,  Next: Adding Global Lisp Variables,  Prev: General Coding Rules,  Up: Rules When Writing New C Code
  590.  
  591. Writing Lisp Primitives
  592. =======================
  593.  
  594.    Lisp primitives are Lisp functions implemented in C.  The details of
  595. interfacing the C function so that Lisp can call it are handled by a few
  596. C macros.  The only way to really understand how to write new C code is
  597. to read the source, but we can explain some things here.
  598.  
  599.    An example of a special form is the definition of `or', from
  600. `eval.c'.  (An ordinary function would have the same general
  601. appearance.)
  602.  
  603.      DEFUN ("or", For, 0, UNEVALLED, 0, /*
  604.      Eval args until one of them yields non-nil, then return that value.
  605.      The remaining args are not evalled at all.
  606.      If all args return nil, return nil.
  607.      */
  608.             (args))
  609.      {
  610.        /* This function can GC */
  611.        REGISTER Lisp_Object val;
  612.        Lisp_Object args_left;
  613.        struct gcpro gcpro1;
  614.      
  615.        if (NILP (args))
  616.          return Qnil;
  617.      
  618.        args_left = args;
  619.        GCPRO1 (args_left);
  620.      
  621.        do
  622.          {
  623.            val = Feval (Fcar (args_left));
  624.            if (!NILP (val))
  625.              break;
  626.            args_left = Fcdr (args_left);
  627.          }
  628.        while (!NILP (args_left));
  629.      
  630.        UNGCPRO;
  631.        return val;
  632.      }
  633.  
  634.    Let's start with a precise explanation of the arguments to the
  635. `DEFUN' macro.  Here is a template for them:
  636.  
  637.      DEFUN (LNAME, FNAME, MIN, MAX, INTERACTIVE, /*
  638.      DOCSTRING
  639.      */
  640.         (ARGLIST) )
  641.  
  642. LNAME
  643.      This string is the name of the Lisp symbol to define as the
  644.      function name; in the example above, it is `"or"'.
  645.  
  646. FNAME
  647.      This is the C function name for this function.  This is the name
  648.      that is used in C code for calling the function.  The name is, by
  649.      convention, `F' prepended to the Lisp name, with all dashes (`-')
  650.      in the Lisp name changed to underscores.  Thus, to call this
  651.      function from C code, call `For'.  Remember that the arguments are
  652.      of type `Lisp_Object'; various macros and functions for creating
  653.      values of type `Lisp_Object' are declared in the file `lisp.h'.
  654.  
  655.      Primitives whose names are special characters (e.g. `+' or `<')
  656.      are named by spelling out, in some fashion, the special character:
  657.      e.g. `Fplus()' or `Flss()'.  Primitives whose names begin with
  658.      normal alphanumeric characters but also contain special characters
  659.      are spelled out in some creative way, e.g. `let*' becomes
  660.      `FletX()'.
  661.  
  662.      Each function also has an associated structure that holds the data
  663.      for the subr object that represents the function in Lisp.  This
  664.      structure conveys the Lisp symbol name to the initialization
  665.      routine that will create the symbol and store the subr object as
  666.      its definition.  The C variable name of this structure is always
  667.      `S' prepended to the FNAME.  You hardly ever need to be aware of
  668.      the existence of this structure.
  669.  
  670. MIN
  671.      This is the minimum number of arguments that the function
  672.      requires.  The function `or' allows a minimum of zero arguments.
  673.  
  674. MAX
  675.      This is the maximum number of arguments that the function accepts,
  676.      if there is a fixed maximum.  Alternatively, it can be `UNEVALLED',
  677.      indicating a special form that receives unevaluated arguments, or
  678.      `MANY', indicating an unlimited number of evaluated arguments (the
  679.      equivalent of `&rest').  Both `UNEVALLED' and `MANY' are macros.
  680.      If MAX is a number, it may not be less than MIN and it may not be
  681.      greater than 8. (If you need to add a function with more than 8
  682.      arguments, either use the `MANY' form or edit the definition of
  683.      `DEFUN' in `lisp.h'.  If you do the latter, make sure to also add
  684.      another clause to the switch statement in `primitive_funcall().')
  685.  
  686. INTERACTIVE
  687.      This is an interactive specification, a string such as might be
  688.      used as the argument of `interactive' in a Lisp function.  In the
  689.      case of `or', it is 0 (a null pointer), indicating that `or'
  690.      cannot be called interactively.  A value of `""' indicates a
  691.      function that should receive no arguments when called
  692.      interactively.
  693.  
  694. DOCSTRING
  695.      This is the documentation string.  It is written just like a
  696.      documentation string for a function defined in Lisp; in
  697.      particular, the first line should be a single sentence.  Note how
  698.      the documentation string is enclosed in a comment, none of the
  699.      documentation is placed on the same lines as the comment-start and
  700.      comment-end characters, and the comment-start characters are on
  701.      the same line as the interactive specification.  `make-docfile',
  702.      which scans the C files for documentation strings, is very
  703.      particular about what it looks for, and will not properly extract
  704.      the doc string if it's not in this exact format.
  705.  
  706.      You are free to put the various arguments to `DEFUN' on separate
  707.      lines to avoid overly long lines.  However, make sure to put the
  708.      comment-start characters for the doc string on the same line as the
  709.      interactive specification, and put a newline directly after them
  710.      (and before the comment-end characters).
  711.  
  712. ARGLIST
  713.      This is the comma-separated list of arguments to the C function.
  714.      For a function with a fixed maximum number of arguments, provide a
  715.      C argument for each Lisp argument.  In this case, unlike regular C
  716.      functions, the types of the arguments are not declared; they are
  717.      simply always of type `Lisp_Object'.
  718.  
  719.      The names of the C arguments will be used as the names of the
  720.      arguments to the Lisp primitive as displayed in its documentation,
  721.      modulo the same concerns described above for `F...' names (in
  722.      particular, underscores in the C arguments become dashes in the
  723.      Lisp arguments).
  724.  
  725.      There is one additional kludge: A trailing `_' on the C argument is
  726.      discarded when forming the Lisp argument.  This allows C language
  727.      reserved words (like `default') or global symbols (like `dirname')
  728.      to be used as argument names without compiler warnings or errors.
  729.  
  730.      A Lisp function with MAX = `UNEVALLED' is a "special form"; its
  731.      arguments are not evaluated.  Instead it receives one argument of
  732.      type `Lisp_Object', a (Lisp) list of the unevaluated arguments,
  733.      conventionally named `(args)'.
  734.  
  735.      When a Lisp function has no upper limit on the number of arguments,
  736.      specify MAX = `MANY'.  In this case its implementation in C
  737.      actually receives exactly two arguments: the number of Lisp
  738.      arguments (an `int') and the address of a block containing their
  739.      values (a `Lisp_Object *').  In this case only are the C types
  740.      specified in the ARGLIST: `(int nargs, Lisp_Object *args)'.
  741.  
  742.    Within the function `For' itself, note the use of the macros
  743. `GCPRO1' and `UNGCPRO'.  `GCPRO1' is used to "protect" a variable from
  744. garbage collection--to inform the garbage collector that it must look
  745. in that variable and regard its contents as an accessible object.  This
  746. is necessary whenever you call `Feval' or anything that can directly or
  747. indirectly call `Feval' (this includes the `QUIT' macro!).  At such a
  748. time, any Lisp object that you intend to refer to again must be
  749. protected somehow.  `UNGCPRO' cancels the protection of the variables
  750. that are protected in the current function.  It is necessary to do this
  751. explicitly.
  752.  
  753.    The macro `GCPRO1' protects just one local variable.  If you want to
  754. protect two, use `GCPRO2' instead; repeating `GCPRO1' will not work.
  755. Macros `GCPRO3' and `GCPRO4' also exist.
  756.  
  757.    These macros implicitly use local variables such as `gcpro1'; you
  758. must declare these explicitly, with type `struct gcpro'.  Thus, if you
  759. use `GCPRO2', you must declare `gcpro1' and `gcpro2'.
  760.  
  761.    Note also that the general rule is "caller-protects"; i.e. you are
  762. only responsible for protecting those Lisp objects that you create.
  763. Any objects passed to you as parameters should have been protected by
  764. whoever created them, so you don't in general have to protect them.
  765. `For' is an exception; it protects its parameters to provide extra
  766. assurance against Lisp primitives elsewhere that are incorrectly
  767. written, and against malicious self-modifying code.  There are a few
  768. other standard functions that also do this.
  769.  
  770.    `GCPRO'ing is perhaps the trickiest and most error-prone part of
  771. XEmacs coding.  It is *extremely* important that you get this right and
  772. use a great deal of discipline when writing this code.  *Note
  773. `GCPRO'ing: GCPROing, for full details on how to do this.
  774.  
  775.    What `DEFUN' actually does is declare a global structure of type
  776. `Lisp_Subr' whose name begins with capital `SF' and which contains
  777. information about the primitive (e.g. a pointer to the function, its
  778. minimum and maximum allowed arguments, a string describing its Lisp
  779. name); `DEFUN' then begins a normal C function declaration using the
  780. `F...' name.  The Lisp subr object that is the function definition of a
  781. primitive (i.e. the object in the function slot of the symbol that
  782. names the primitive) actually points to this `SF' structure; when
  783. `Feval' encounters a subr, it looks in the structure to find out how to
  784. call the C function.
  785.  
  786.    Defining the C function is not enough to make a Lisp primitive
  787. available; you must also create the Lisp symbol for the primitive (the
  788. symbol is "interned"; *note Obarrays::.) and store a suitable subr
  789. object in its function cell. (If you don't do this, the primitive won't
  790. be seen by Lisp code.) The code looks like this:
  791.  
  792.      DEFSUBR (FNAME);
  793.  
  794. Here FNAME is the name you used as the second argument to `DEFUN'.
  795.  
  796.    This call to `DEFSUBR' should go in the `syms_of_*()' function at
  797. the end of the module.  If no such function exists, create it and make
  798. sure to also declare it in `symsinit.h' and call it from the
  799. appropriate spot in `main()'.  *Note General Coding Rules::.
  800.  
  801.    Note that C code cannot call functions by name unless they are
  802. defined in C.  The way to call a function written in Lisp from C is to
  803. use `Ffuncall', which embodies the Lisp function `funcall'.  Since the
  804. Lisp function `funcall' accepts an unlimited number of arguments, in C
  805. it takes two: the number of Lisp-level arguments, and a one-dimensional
  806. array containing their values.  The first Lisp-level argument is the
  807. Lisp function to call, and the rest are the arguments to pass to it.
  808. Since `Ffuncall' can call the evaluator, you must protect pointers from
  809. garbage collection around the call to `Ffuncall'. (However, `Ffuncall'
  810. explicitly protects all of its parameters, so you don't have to protect
  811. any pointers passed as parameters to it.)
  812.  
  813.    The C functions `call0', `call1', `call2', and so on, provide handy
  814. ways to call a Lisp function conveniently with a fixed number of
  815. arguments.  They work by calling `Ffuncall'.
  816.  
  817.    `eval.c' is a very good file to look through for examples; `lisp.h'
  818. contains the definitions for some important macros and functions.
  819.  
  820. 
  821. File: internals.info,  Node: Adding Global Lisp Variables,  Next: Techniques for XEmacs Developers,  Prev: Writing Lisp Primitives,  Up: Rules When Writing New C Code
  822.  
  823. Adding Global Lisp Variables
  824. ============================
  825.  
  826.    Global variables whose names begin with `Q' are constants whose
  827. value is a symbol of a particular name.  The name of the variable should
  828. be derived from the name of the symbol using the same rules as for Lisp
  829. primitives.  These variables are initialized using a call to
  830. `defsymbol()' in the `syms_of_*()' function. (This call interns a
  831. symbol, sets the C variable to the resulting Lisp object, and calls
  832. `staticpro()' on the C variable to tell the garbage-collection
  833. mechanism about this variable.  What `staticpro()' does is add a
  834. pointer to the variable to a large global array; when
  835. garbage-collection happens, all pointers listed in the array are used
  836. as starting points for marking Lisp objects.  This is important because
  837. it's quite possible that the only current reference to the object is
  838. the C variable.  In the case of symbols, the `staticpro()' doesn't
  839. matter all that much because the symbol is contained in `obarray',
  840. which is itself `staticpro()'ed.  However, it's possible that a naughty
  841. user could do something like uninterning the symbol out of `obarray' or
  842. even setting `obarray' to a different value [although this is likely to
  843. make XEmacs crash!].)
  844.  
  845.    *Note:* It is potentially deadly if you declare a `Q...'  variable
  846. in two different modules.  The two calls to `defsymbol()' are no
  847. problem, but some linkers will complain about multiply-defined symbols.
  848. The most insidious aspect of this is that often the link will succeed
  849. anyway, but then the resulting executable will sometimes crash in
  850. obscure ways during certain operations!  To avoid this problem, declare
  851. any symbols with common names (such as `text') that are not obviously
  852. associated with this particular module in the module `general.c'.
  853.  
  854.    Global variables whose names begin with `V' are variables that
  855. contain Lisp objects.  The convention here is that all global variables
  856. of type `Lisp_Object' begin with `V', and all others don't (including
  857. integer and boolean variables that have Lisp equivalents). Most of the
  858. time, these variables have equivalents in Lisp, but some don't.  Those
  859. that do are declared this way by a call to `DEFVAR_LISP()' in the
  860. `vars_of_*()' initializer for the module.  What this does is create a
  861. special "symbol-value-forward" Lisp object that contains a pointer to
  862. the C variable, intern a symbol whose name is as specified in the call
  863. to `DEFVAR_LISP()', and set its value to the symbol-value-forward Lisp
  864. object; it also calls `staticpro()' on the C variable to tell the
  865. garbage-collection mechanism about the variable.  When `eval' (or
  866. actually `symbol-value') encounters this special object in the process
  867. of retrieving a variable's value, it follows the indirection to the C
  868. variable and gets its value.  `setq' does similar things so that the C
  869. variable gets changed.
  870.  
  871.    Whether or not you `DEFVAR_LISP()' a variable, you need to
  872. initialize it in the `vars_of_*()' function; otherwise it will end up
  873. as all zeroes, which is the integer 0 (*not* `nil'), and this is
  874. probably not what you want.  Also, if the variable is not
  875. `DEFVAR_LISP()'ed, *you must call* `staticpro()' on the C variable in
  876. the `vars_of_*()' function.  Otherwise, the garbage-collection
  877. mechanism won't know that the object in this variable is in use, and
  878. will happily collect it and reuse its storage for another Lisp object,
  879. and you will be the one who's unhappy when you can't figure out how
  880. your variable got overwritten.
  881.  
  882. 
  883. File: internals.info,  Node: Techniques for XEmacs Developers,  Prev: Adding Global Lisp Variables,  Up: Rules When Writing New C Code
  884.  
  885. Techniques for XEmacs Developers
  886. ================================
  887.  
  888.    To make a quantified XEmacs, do: `make quantmacs'.
  889.  
  890.    You simply can't dump Quantified and Purified images.  Run the image
  891. like so:  `quantmacs -batch -l loadup.el run-temacs -q'.
  892.  
  893.    Before you go through the trouble, are you compiling with all
  894. debugging and error-checking off?  If not try that first.  Be warned
  895. that while Quantify is directly responsible for quite a few
  896. optimizations which have been made to XEmacs, doing a run which
  897. generates results which can be acted upon is not necessarily a trivial
  898. task.
  899.  
  900.    Also, if you're still willing to do some runs make sure you configure
  901. with the `--quantify' flag.  That will keep Quantify from starting to
  902. record data until after the loadup is completed and will shut off
  903. recording right before it shuts down (which generates enough bogus data
  904. to throw most results off).  It also enables three additional elisp
  905. commands: `quantify-start-recording-data',
  906. `quantify-stop-recording-data' and `quantify-clear-data'.
  907.  
  908.    To get started debugging XEmacs, take a look at the `gdbinit' and
  909. `dbxrc' files in the `src' directory.
  910.  
  911. 
  912. File: internals.info,  Node: A Summary of the Various XEmacs Modules,  Next: Allocation of Objects in XEmacs Lisp,  Prev: Rules When Writing New C Code,  Up: Top
  913.  
  914. A Summary of the Various XEmacs Modules
  915. ***************************************
  916.  
  917.    This is accurate as of XEmacs 20.0.
  918.  
  919. * Menu:
  920.  
  921. * Low-Level Modules::
  922. * Basic Lisp Modules::
  923. * Modules for Standard Editing Operations::
  924. * Editor-Level Control Flow Modules::
  925. * Modules for the Basic Displayable Lisp Objects::
  926. * Modules for other Display-Related Lisp Objects::
  927. * Modules for the Redisplay Mechanism::
  928. * Modules for Interfacing with the File System::
  929. * Modules for Other Aspects of the Lisp Interpreter and Object System::
  930. * Modules for Interfacing with the Operating System::
  931. * Modules for Interfacing with X Windows::
  932. * Modules for Internationalization::
  933.  
  934. 
  935. File: internals.info,  Node: Low-Level Modules,  Next: Basic Lisp Modules,  Up: A Summary of the Various XEmacs Modules
  936.  
  937. Low-Level Modules
  938. =================
  939.  
  940.         size  name
  941.      -------  ---------------------
  942.        18150  config.h
  943.  
  944.    This is automatically generated from `config.h.in' based on the
  945. results of configure tests and user-selected optional features and
  946. contains preprocessor definitions specifying the nature of the
  947. environment in which XEmacs is being compiled.
  948.  
  949.         2347  paths.h
  950.  
  951.    This is automatically generated from `paths.h.in' based on supplied
  952. configure values, and allows for non-standard installed configurations
  953. of the XEmacs directories.  It's currently broken, though.
  954.  
  955.        47878  emacs.c
  956.        20239  signal.c
  957.  
  958.    `emacs.c' contains `main()' and other code that performs the most
  959. basic environment initializations and handles shutting down the XEmacs
  960. process (this includes `kill-emacs', the normal way that XEmacs is
  961. exited; `dump-emacs', which is used during the build process to write
  962. out the XEmacs executable; `run-emacs-from-temacs', which can be used
  963. to start XEmacs directly when temacs has finished loading all the Lisp
  964. code; and emergency code to handle crashes [XEmacs tries to auto-save
  965. all files before it crashes]).
  966.  
  967.    Low-level code that directly interacts with the Unix signal
  968. mechanism, however, is in `signal.c'.  Note that this code does not
  969. handle system dependencies in interfacing to signals; that is handled
  970. using the `syssignal.h' header file, described in section J below.
  971.  
  972.        23458  unexaix.c
  973.         9893  unexalpha.c
  974.        11302  unexapollo.c
  975.        16544  unexconvex.c
  976.        31967  unexec.c
  977.        30959  unexelf.c
  978.        35791  unexelfsgi.c
  979.         3207  unexencap.c
  980.         7276  unexenix.c
  981.        20539  unexfreebsd.c
  982.         1153  unexfx2800.c
  983.        13432  unexhp9k3.c
  984.        11049  unexhp9k800.c
  985.         9165  unexmips.c
  986.         8981  unexnext.c
  987.         1673  unexsol2.c
  988.        19261  unexsunos4.c
  989.  
  990.    These modules contain code dumping out the XEmacs executable on
  991. various different systems. (This process is highly machine-specific and
  992. requires intimate knowledge of the executable format and the memory map
  993. of the process.) Only one of these modules is actually used; this is
  994. chosen by `configure'.
  995.  
  996.        15715  crt0.c
  997.         1484  lastfile.c
  998.         1115  pre-crt0.c
  999.  
  1000.    These modules are used in conjunction with the dump mechanism.  On
  1001. some systems, an alternative version of the C startup code (the actual
  1002. code that receives control from the operating system when the process is
  1003. started, and which calls `main()') is required so that the dumping
  1004. process works properly; `crt0.c' provides this.
  1005.  
  1006.    `pre-crt0.c' and `lastfile.c' should be the very first and very last
  1007. file linked, respectively. (Actually, this is not really true.
  1008. `lastfile.c' should be after all Emacs modules whose initialized data
  1009. should be made constant, and before all other Emacs files and all
  1010. libraries.  In particular, the allocation modules `gmalloc.c',
  1011. `alloca.c', etc. are normally placed past `lastfile.c', and all of the
  1012. files that implement Xt widget classes *must* be placed after
  1013. `lastfile.c' because they contain various structures that must be
  1014. statically initialized and into which Xt writes at various times.)
  1015. `pre-crt0.c' and `lastfile.c' contain exported symbols that are used to
  1016. determine the start and end of XEmacs' initialized data space when
  1017. dumping.
  1018.  
  1019.        14786  alloca.c
  1020.        16678  free-hook.c
  1021.         1692  getpagesize.h
  1022.        41936  gmalloc.c
  1023.        25141  malloc.c
  1024.         3802  mem-limits.h
  1025.        39011  ralloc.c
  1026.         3436  vm-limit.c
  1027.  
  1028.    These handle basic C allocation of memory.  `alloca.c' is an
  1029. emulation of the stack allocation function `alloca()' on machines that
  1030. lack this. (XEmacs makes extensive use of `alloca()' in its code.)
  1031.  
  1032.    `gmalloc.c' and `malloc.c' are two implementations of the standard C
  1033. functions `malloc()', `realloc()' and `free()'.  They are often used in
  1034. place of the standard system-provided `malloc()' because they usually
  1035. provide a much faster implementation, at the expense of additional
  1036. memory use.  `gmalloc.c' is a newer implementation that is much more
  1037. memory-efficient for large allocations than `malloc.c', and should
  1038. always be preferred if it works. (At one point, `gmalloc.c' didn't work
  1039. on some systems where `malloc.c' worked; but this should be fixed now.)
  1040.  
  1041.    `ralloc.c' is the "relocating allocator".  It provides functions
  1042. similar to `malloc()', `realloc()' and `free()' that allocate memory
  1043. that can be dynamically relocated in memory.  The advantage of this is
  1044. that allocated memory can be shuffled around to place all the free
  1045. memory at the end of the heap, and the heap can then be shrunk,
  1046. releasing the memory back to the operating system.  The use of this can
  1047. be controlled with the configure option `--rel-alloc'; if enabled,
  1048. memory allocated for buffers will be relocatable, so that if a very
  1049. large file is visited and the buffer is later killed, the memory can be
  1050. released to the operating system.  (The disadvantage of this mechanism
  1051. is that it can be very slow.  On systems with the `mmap()' system call,
  1052. the XEmacs version of `ralloc.c' uses this to move memory around
  1053. without actually having to block-copy it, which can speed things up;
  1054. but it can still cause noticeable performance degradation.)
  1055.  
  1056.    `free-hook.c' contains some debugging functions for checking for
  1057. invalid arguments to `free()'.
  1058.  
  1059.    `vm-limit.c' contains some functions that warn the user when memory
  1060. is getting low.  These are callback functions that are called by
  1061. `gmalloc.c' and `malloc.c' at appropriate times.
  1062.  
  1063.    `getpagesize.h' provides a uniform interface for retrieving the size
  1064. of a page in virtual memory.  `mem-limits.h' provides a uniform
  1065. interface for retrieving the total amount of available virtual memory.
  1066. Both are similar in spirit to the `sys*.h' files described in section
  1067. J, below.
  1068.  
  1069.         2659  blocktype.c
  1070.         1410  blocktype.h
  1071.         7194  dynarr.c
  1072.         2671  dynarr.h
  1073.  
  1074.    These implement a couple of basic C data types to facilitate memory
  1075. allocation.  The `Blocktype' type efficiently manages the allocation of
  1076. fixed-size blocks by minimizing the number of times that `malloc()' and
  1077. `free()' are called.  It allocates memory in large chunks, subdivides
  1078. the chunks into blocks of the proper size, and returns the blocks as
  1079. requested.  When blocks are freed, they are placed onto a linked list,
  1080. so they can be efficiently reused.  This data type is not much used in
  1081. XEmacs currently, because it's a fairly new addition.
  1082.  
  1083.    The `Dynarr' type implements a "dynamic array", which is similar to
  1084. a standard C array but has no fixed limit on the number of elements it
  1085. can contain.  Dynamic arrays can hold elements of any type, and when
  1086. you add a new element, the array automatically resizes itself if it
  1087. isn't big enough.  Dynarrs are extensively used in the redisplay
  1088. mechanism.
  1089.  
  1090.         2058  inline.c
  1091.  
  1092.    This module is used in connection with inline functions (available in
  1093. some compilers).  Often, inline functions need to have a corresponding
  1094. non-inline function that does the same thing.  This module is where they
  1095. reside.  It contains no actual code, but defines some special flags that
  1096. cause inline functions defined in header files to be rendered as actual
  1097. functions.  It then includes all header files that contain any inline
  1098. function definitions, so that each one gets a real function equivalent.
  1099.  
  1100.         6489  debug.c
  1101.         2267  debug.h
  1102.  
  1103.    These functions provide a system for doing internal consistency
  1104. checks during code development.  This system is not currently used;
  1105. instead the simpler `assert()' macro is used along with the various
  1106. checks provided by the `--error-check-*' configuration options.
  1107.  
  1108.         1643  prefix-args.c
  1109.  
  1110.    This is actually the source for a small, self-contained program used
  1111. during building.
  1112.  
  1113.          904  universe.h
  1114.  
  1115.    This is not currently used.
  1116.  
  1117.